{-# LANGUAGE ScopedTypeVariables, TypeOperators #-}
----------------------------------------------------------------------
-- |
-- Module      :  Model.Pickles
-- Copyright   :  (c) Sergey Sichevskiy 2012
-- License     :  BSD3
-- 
-- Maintainer  :  s.sichevskij@gmal.com
-- Stability   :  experimental
--  
-- Модель звездных спектров
--
----------------------------------------------------------------------

module Model.Pickles
 ( model
 ) where

import Types
import Model

import Data.HList
import Data.VectorSpace     ( (^/) )
import Control.Monad.Reader ( asks )

--model :: (ModelFlux -> Double -> SED) -> Factory (Model SED)
--model :: (ModelFlux -> (Double -> SED, Double -> Double )) -> Factory ( (Double ::: Double ::: Null) -> (Sp ::: Dist ::: Null), (Sp:::Dist:::Null) -> SED )
model :: (ModelFlux -> (Double -> SED, Double -> Double )) -> Factory ( (Double :::  Null) -> (Sp :::  Null), (Sp ::: Null) -> SED )
model luminosityClass = do

  (f,m) <- asks $ luminosityClass . modelflux

{--
  let flux (Sp sp ::: Dist d ::: Null) = (f sp) ^/ d**2
  let fm (x ::: y ::: Null) = (Sp sp ::: Dist d ::: Null)
        where
         (sp, d) = (m x, y)
--}
  let flux (Sp sp ::: Null) = f sp

  let fm (x ::: Null) = (Sp (m x) ::: Null)
   
  return (fm, flux)